<script type="text/javascript" >
$(document).ready(function(){
	$("#tgl_awal").datepicker({
		dateFormat: 'yy-mm-dd'
	});
	$("#tgl_akhir").datepicker({
		dateFormat: 'yy-mm-dd'
	});
	$(".link_detail").fancybox({
		'overlayShow'	: false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic'
	});
});
</script>
<div id="tiga_ba">
	<div id="tiga_baa">Verifikasi RITL-RITL</div>
	
	<div class="clear"></div>
</div>
<?php
require_once 'config/fungsi_laporan.php';

	$tgl_awal=$_POST['tgl_awal'];
	$tgl_akhir=$_POST['tgl_akhir'];
	$nama_ppk=$_POST['nama_ppk'];	
	$jenis_klaim=$_POST['jenis_klaim'];
	$jml=$_POST['jml'];
	
	
?>
<form method=post action='utama.php?module=mod_verifikasi_ritl'>
	<table style="margin-left: 5px;" width="780" >
		<tr>
			<td width="65">Tgl Awal  : </td>
			<td width="200"><input type="text" name="tgl_awal" id="tgl_awal" value="<?php echo $tgl_awal; ?>" class="input_field" /></td>
			<td></td>
		</tr>
		<tr>
			<td width="65">Tgl Akhir  : </td>
			<td width="200"><input type="text" name="tgl_akhir" id="tgl_akhir" value="<?php echo $tgl_akhir; ?>" class="input_field" /></td>
			
		</tr>
		<tr>
			<td width="65">PPK  : </td>
			<td width="200"><?php edit_kombo_baru("ppk","nama_ppk","input_field","id_ppk","nama",$nama_ppk)?></td>
		
		</tr>
		<tr>
			<td width="65">Jumlah :</td>
			<td width="200"><?php
				for($i=1;$i<=10;$i++){
					$arr_jml[$i]=$i;
				}
			kombo_from_array("jml","input_field",$arr_jml,$jml);?></td>
		
		</tr>
		<tr>
			<td width="65">Jenis : </td>
			<td width="200"><?php 
			$arr_jenis=array('service'=>'Fee For Service','inacbg'=>'Ina CBG');
			kombo_from_array("jenis_klaim","input_field",$arr_jenis,$jenis_klaim);?></td>
		
		</tr>
		<tr>
			<td width="65"></td>
			<td><input name="submit" type="submit" class="button" value="Cari" /></td>
		</tr>
	</table>
</form>

<table class="tabel">
	<tr>
		<th>NO</th>
		<th>Tgl Masuk</th>
		<th>Tgl Keluar</th>
		<th>LOS</th>
		<th>No RM</th>
		<th>Nama</th>
		<th>Umur</th>
		<th>Detail</th>
		<th>Status</th>
	</tr>
	<?php
		$p= new paging ;
		$batas= 10;
		
		//cek halaman dan posisi halaman
		$posisi = $p ->cariposisi($batas) ;
		//$sql="select * from klaim order by id_peserta asc ";
		$sql="select a.*,pn.nama as nama_penduduk,jp.jenis_peserta,jl.jenis_layanan,
		pk.nama as nama_ppk,ifnull(a.id_status,0) as status
		from klaim a inner join  peserta p on a.id_peserta = p.id_peserta 
		inner join penduduk pn on p.id_penduduk = pn.id_penduduk 
		inner join jenis_peserta jp on p.id_jenis_peserta=jp.id_jenis_peserta
		inner join jenis_layanan jl on a.id_jenis_layanan=jl.id_jenis_layanan
		inner join ppk pk on a.id_ppk=pk.id_ppk
		where  a.tgl_trans between '$tgl_awal' and '$tgl_akhir'
		and a.id_ppk='$nama_ppk' and a.id_jenis_layanan='3' and a.jenis_klaim='$jenis_klaim' order by a.id_peserta asc";
		echo $sql;
		$qry=mysql_query($sql);
		$tmp_idpeserta="";
		$tmp_tglkeluar=date('Y-m-d');
		$count=0;
		echo "<pre>";
		while($hasil=mysql_fetch_assoc($qry)){
			//$tmp_tglkeluar=$hasil['tgl_keluar'];
			//$selisih_tgl=selisih_tgl($hasil['tgl_masuk'],$tmp_tglkeluar);
			//echo 'id peserta '.$hasil['id_peserta']." ";
			if($tmp_idpeserta<>$hasil['id_peserta']){
				$tmp_idpeserta=$hasil['id_peserta'];
				$tgl_masuk=$hasil['tgl_masuk'];
				$tgl_keluar=$hasil['tgl_keluar'];
				echo "baru ";
				print_r($hasil);
				unset($arr_klaim[$count-1]);
				$arr_klaim[]=$hasil;
				
			}else {
				
			$selisih_tgl=selisih_tgl($tmp_tglkeluar,$hasil['tgl_masuk']);
			if($selisih_tgl <= $jml){
				$arr_klaim[]=$hasil;//array('id_peserta'=>$hasil['id_peserta'],'id_klaim'=>$hasil['id_klaim']);
			}else{
				unset($arr_klaim[$count-1]);
				echo 'dihapus '.$arr_klaim[$count-1];
			}
			}
			$count++;
			$tmp_tglkeluar=$hasil['tgl_keluar'];
		}
		$jml_arr=count($arr_klaim);
		//echo "<pre>";
		//print_r($arr_klaim);
		$no=$posisi + 1;
		if($jml_arr>0){
		
			//while($hasil=mysql_fetch_array($qry)){
			foreach($arr_klaim as $key=>$val){
	?>
	<form method=post action='utama.php?module=mod_verifikasi_ritl&act=simpan_status'>
	<tr>
		<td align="center" width="30"><?php echo $no; ?></td>
		<td ><?php echo tgl_indonesia($val['tgl_masuk']);?></td>
		<td ><?php echo tgl_indonesia($val['tgl_keluar']);?></td>
		<td ><?php echo $val['nama_penduduk'];?></td>
		<td ><?php echo $val['no_rm'];?></td>
		<td ><?php echo $val['nama_penduduk'];?></td>
		<td ><?php echo konversi_hari($val['umur']);?></td>
		<td ><a class="link_detail" href="module/mod_klaim/form_detail.php?id=<?php echo $val['id_klaim']?>"><img src="asset/images/detail.png"></a></td>
		<td align="center" width="60">
			<input type="hidden" name="id_klaim[]" value="<?php echo $val['id_klaim'];?>" />
			<?php
				$arr_status=array('0'=>'Pending','3'=>'Diterima','4'=>'Ditolak');
				kombo_from_array("status_verifikasi[]","",$arr_status,$val['status']);
			?>
		</td>
	</tr>
	<?php
				$no++;
			}
	?>
	<tr>
		<td colspan="9" align="left"><input name="submit" type="submit" class="button" value="Simpan Verifikasi" /></td>
	</tr>
	<?php
		}else{
		?>
	
	<tr>
		<td colspan="9" align="center">Data tidak Ada </td>
	</tr>
	<?php
		}
	?>
</table>
